using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class JobSeekers_educations : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session.Contents["jsuserid"] == null)
        {
                Response.Redirect("login.aspx");
        }
        else        
        {
            if(!IsPostBack)
            {
                ShowEducation();
            }
        }
    }
    protected void btnNext_Click(object sender, EventArgs e)
    {
        Response.Redirect("experiences.aspx");
    }
    protected void btnDelete_Click(object sender, EventArgs e)
    {
        DeleteEducation();
        ShowEducation();
    }
    void ShowEducation()
    {
        SQLServerProviders cls = new SQLServerProviders();
        DataTable dataTable = cls.GetDataTable(
        "select EducationID,School, Country ,"
        + " Faculty ,Graduate ,Major" +
        "  from tblJSEducations" +
        " where UserID='" + Convert.ToString(
        Session.Contents["jsuserid"])
        + "'", CommandType.Text);
        GridView1.DataSource = dataTable;
        GridView1.DataBind();
    }
    void DeleteEducation()
    {
        string educationID="";
        foreach(GridViewRow item in GridView1.Rows)
        {
            CheckBox checkBox = (CheckBox)item.Cells[0].FindControl("chkEducationID");
            if(checkBox.Checked)
                educationID+= item.Cells[0].Text +",";
        }
        if(educationID!="")
        {
            SQLServerProviders cls = new SQLServerProviders();
            cls.ExecuteNonQuery(
            "delete  from tblJSEducations" +
            " where UserID='" + Convert.ToString(
            Session.Contents["jsuserid"])
            + "' and educationID in('" + 
            educationID.Replace(",","','")+ "')", 
            CommandType.Text);
        }
    }
    protected void btnNew_Click(object sender, EventArgs e)
    {
        Response.Redirect("education.aspx");
    }
}
